package org.stbernardpreserve.learning.effectivejava.builder;

public class BeerProfileImmutableWithABuilder implements BeerProfile {

	private final int specificGravity;
	private final String color;
	private final double bitterness;
	private final double carbonation;
	private final int temperature;

	public BeerProfileImmutableWithABuilder(BeerProfileBuilder beerProfileBuilder) {
		specificGravity = beerProfileBuilder.specificGravity;
		color = beerProfileBuilder.color;
		bitterness = beerProfileBuilder.bitterness;
		carbonation = beerProfileBuilder.carbonation;
		temperature = beerProfileBuilder.temperature;
	}

	public static class BeerProfileBuilder {
		private int specificGravity = 0;
		private final String color;
		private double bitterness = 0;
		private double carbonation = 0;
		private final int temperature;

		public BeerProfileBuilder(int temperature, String color) {
			this.color = color;
			this.temperature = temperature;
		}

		public BeerProfileBuilder specificGravity(int specificGravity) {
			this.specificGravity = specificGravity;
			return this;
		}

		public BeerProfileBuilder bitterness(int bitterness) {
			this.bitterness = bitterness;
			return this;
		}

		public BeerProfileBuilder carbonation(int carbonation) {
			this.carbonation = carbonation;
			return this;
		}
		
		public BeerProfileImmutableWithABuilder build() {
			return new BeerProfileImmutableWithABuilder(this);
		}

	}

	public int getSpecificGravity() {
		return specificGravity;
	}

	public String getColor() {
		return color;
	}

	public double getBitterness() {
		return bitterness;
	}

	public double getCarbonation() {
		return carbonation;
	}

	public int getTemperature() {
		return temperature;
	}
}
